// =====================================================
// TypeScript 类型定义
// =====================================================

// API 响应基础类型
export interface ApiResponse<T = any> {
  code: number;
  message: string;
  data: T;
}

// 订阅源类型
export interface Feed {
  id: number;
  url: string;
  title: string;
  description: string;
  site_url: string;
  icon_url: string;
  category: string;
  last_fetched_at: string;
  fetch_interval: number;
  is_active: boolean;
  article_count: number;
  created_at: string;
  updated_at: string;
}

// 文章类型
export interface Article {
  id: number;
  feed_id: number;
  feed?: Feed;
  guid: string;
  title: string;
  link: string;
  author?: string;
  published_at: string;
  description?: string;
  content: string;
  ai_summary?: string;
  ai_tags?: string[] | null;
  ai_generated_at?: string | null;
  is_read: boolean;
  is_starred: boolean;
  user_note?: string;
  created_at: string;
  updated_at: string;
}

// 分页数据类型
export interface PaginatedArticles {
  articles: Article[];
  total: number;
  page: number;
  size: number;
}

// 文章查询参数
export interface ArticleQuery {
  page?: number;
  size?: number;
  feed_id?: number;
  is_read?: boolean;
  is_starred?: boolean;
  keyword?: string;
  start_date?: string;
  end_date?: string;
}

// 订阅源统计
export interface FeedStats {
  total: number;
  active: number;
  inactive: number;
  categories: Record<string, number>;
}

// 文章统计
export interface ArticleStats {
  total: number;
  read: number;
  unread: number;
  starred: number;
  today: number;
  this_week: number;
  this_month: number;
}

// 刷新结果
export interface RefreshResult {
  message: string;
  new_articles?: number;
}

// 批量刷新结果
export interface BatchRefreshResult {
  total: number;
  success: number;
  failed: number;
  new_articles: number;
  duration: number;
  failed_feeds: Array<{
    id: number;
    title: string;
    error: string;
  }>;
}
